package com.kh.statistics.video.controller;

import com.kh.statistics.video.base.ClientEnum;
import com.kh.statistics.video.entity.Accounts;
import com.kh.statistics.video.entity.VideoAccountStatusVO;
import com.kh.statistics.video.entity.VideoAccountsLogin;
import com.kh.statistics.video.exception.ResponseVO;
import com.kh.statistics.video.service.VideoAccountsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.List;

/**
 * @BelongsProject: statistics
 * @BelongsPackage: com.kh.statistics.video.controller
 * @Author: Hong.Kong
 * @CreateTime: 2024-05-11  10:31
 * @Description: TODO
 * @Version: 1.0
 */
@RestController
@RequestMapping("video/account")
public class VideoAccountsController {

    @Autowired
    private VideoAccountsService videoAccountsService;

    @PostMapping("accountStatusList")
    public ResponseVO<List<VideoAccountStatusVO>> searchAccountStatusList() {
        return ResponseVO.success(videoAccountsService.searchAccountStatusList());
    }

    @PostMapping("login")
    public void login(@RequestBody VideoAccountsLogin videoAccountsLogin) throws IOException {
        if (null == videoAccountsLogin) {
            return;
        }
        videoAccountsService.login(videoAccountsLogin);
    }


    @PostMapping("add")
    public ResponseVO<Boolean> add(@RequestBody Accounts accounts) throws IOException {
        videoAccountsService.add(accounts);
        return ResponseVO.success(true);
    }


    @PostMapping("search")
    public ResponseVO<List<Accounts>> search(@RequestBody Accounts accounts) throws IOException {
        return ResponseVO.success(videoAccountsService.search(accounts));
    }

    @PostMapping("deleteById")
    public ResponseVO<Boolean> deleteById(@RequestBody Accounts accounts) throws IOException {
        return ResponseVO.success(videoAccountsService.deleteById(accounts));
    }

    @PostMapping("update")
    public ResponseVO<Boolean> update(@RequestBody Accounts accounts) throws IOException {
        return ResponseVO.success(videoAccountsService.update(accounts));
    }
}
